import { Inject } from '@midwayjs/core';
import { CoolController, BaseController } from '@cool-midway/core';
import { DeviceInfoEntity } from '../../entity/info';
import { DeviceInfoService } from '../../service/info';
import { BaseSysUserEntity } from '../../../base/entity/sys/user';

/**
 * 设备信息
 */
@CoolController({
  api: ['add', 'delete', 'update', 'info', 'list', 'page'],
  entity: DeviceInfoEntity,
  service: DeviceInfoService,
  pageQueryOp: {
    keyWordLikeFields: ['a.name', 'a.macAddress'],
    fieldEq: ['a.storeId', 'a.status'],
    select: ['a.*', 'b.username as ownerName'],
    join: [
      {
        entity: BaseSysUserEntity,
        alias: 'b',
        condition: 'a.ownerId = b.id',
        type: 'leftJoin',
      },
    ],
  },
})
export class AdminDeviceInfoController extends BaseController {
  @Inject()
  deviceInfoService: DeviceInfoService;
}
